<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link href="<%=application.getContextPath() %>/css/css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=application.getContextPath() %>/js/jquery-1.6.min.js"></script>	
<script language="javascript" src="<%=application.getContextPath() %>/js/calendar_eu.js"></script>
<script type="text/javascript" src="<%=application.getContextPath() %>/js/jquery-ui-1.8.17.custom.min.js"></script>	
<link rel="stylesheet" href="<%=application.getContextPath() %>/css/jquery-ui-1.8.17.custom.css"/>
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery.validate.js"></script>	
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery.validate.min.js"></script>
 <script>

	$(function() {
		$( "#strDate" ).datepicker({ dateFormat: "dd-mm-yy" });
	});
	</script>
     <script>

	$(function() {
		$( "#endDate" ).datepicker({ dateFormat: "dd-mm-yy" });
	});
	</script>
	<script>
  $(document).ready(function(){
    $("#prjForm").validate({
        
  messages: {
	  org:
      {
          required: "Organisation must not be empty.",
      },
      nameOfPrj:
      {
          required: "Project Name must not be empty.",
          
      },
      nameOfUser:
      {
          required: " Name Of the User must not be empty.",
      }
      
   
  }
});
  });
  </script>
  <style>
  	#field, label { float: left; font-family: Arial, Helvetica, sans-serif; font-size: 11px; }
  	label {  width: 14em; }
	br { clear: both; }
	input.error { border: 1px solid red;  }
	select.error{ border: 1px solid red;  }
	label.error {
		padding-left: 16px;
		margin-left: .3em;
		color: red;
	}
	.textfield{
		height: 22px;
		width: 180px; 
	}
	.textarea1{
		height: 52px;
		width: 180px;
	}
	</style>
</head>
<body>
<table width="927" style="height:880px" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td height="116" align="left" valign="top" background="<%=application.getContextPath() %>/images/top-bg.jpg" style="background-repeat:repeat-x; background-position:left top">
    <%@ include file="common/exe-header.jsp" %>
    </td>
  </tr>
  <tr>
    <td  align="center" valign="top"><table width="927" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="20">&nbsp;</td>
        <td width="643" align="right"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td align="left" valign="top">&nbsp;<a href="<%=application.getContextPath() %>/user/open.do"><img src="<%=application.getContextPath() %>/images/home1.jpg" width="20" height="20" border="0" /></a></td>
              <td width="8%" align="center"><a href="<%=application.getContextPath() %>/user/logout.do" style="font-family: sans-serif;">&nbsp;&nbsp;Logout</a></td>
            </tr>
          </table>
        </td>
        <td width="20">&nbsp;</td>
      </tr>
      <tr>
        <td width="20">&nbsp;</td>
        <td align="center" valign="top" class="heading">Project</td>
        <td width="20">&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td align="right"></td>
        <td>&nbsp;</td>
      </tr>
      <%
      if(request.getParameter("msg")!=null){
      	out.println(request.getParameter("msg"));
      }
      %>
      <tr>
        <td>&nbsp;</td>
        <td align="center" valign="top">
        <form action="<%=application.getContextPath() %>/project/save.do" method="post" name="prjForm" id="prjForm">
        <table width="870" border="0" cellspacing="0" cellpadding="0">
       <tr>
            <td align="left" valign="top">
           <table width="895" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td>
                
                <table width="100%" border="0" cellpadding="0" cellspacing="0" class="box-border1">
                  <tr>
                    <td width="366"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                        <tr>
                          <td width="29">&nbsp;</td>
                          <td width="168">&nbsp;</td>
                          <td width="250">&nbsp;</td>
                          <td width="23">&nbsp;</td>
                        </tr>
                        <tr>
                          <td height="28">&nbsp;</td>
                          <td align="left" valign="top" class="content">Organisation Name</td>
                          <td align="left" valign="top">
                         <table width="100%" border="0" cellpadding="0" cellspacing="0">
                          <tr>
                          	<td width="83%" align="left" valign="top"> <input type="hidden" id="orglist" value="<%=request.getAttribute("acList")%>"/>
                         
                          <input type="text" name="org" id="org" class="textfield required"  value=""  tabindex="1"/></td>
                            <td width="17%" align="left" valign="top"></td>
                          </tr>
                          </table></td>
                          <td align="left" valign="top"></td>
                        </tr>
                        <tr>
                          <td height="5"></td>
                          <td height="5" align="left" valign="top" class="content"></td>
                          <td height="5" align="left" valign="top"></td>
                          <td align="left" valign="top"></td>
                        </tr>
                        
                        <tr>
                          <td>&nbsp;</td>
                          <td align="left" valign="top" height="28" class="content">Industry Type </td>
                          <td align="left" valign="top">
                          <select name="indsType" id="indsType" class="textfield"  tabindex="3">
                          <option value="">Please Select</option>
                          <option value="Electrical">Electrical</option>
                          <option value="Electronics">Electronics</option>
                          <option value="Cement">Cement</option>
                          <option value="Railways">Railways</option>
                          <option value="Power">Power</option>
                          <option value="Nuclear">Nuclear</option>
                          <option value="Construction">Construction</option>
                          <option value="Fabrication">Fabrication</option>
                          <option value="Chemical">Chemical</option>
                          <option value="Mechanical">Mechanical</option>
                          <option value="Irrigation">Irrigation</option>
                          <option value="Agriculture">Agriculture</option>
                         
                      </select>
                          </td>
                          <td align="left" valign="top"></td>
                        </tr>
                        <tr>
                          <td height="5"></td>
                          <td height="5" align="left" valign="top" class="content"></td>
                          <td height="5" align="left" valign="top"></td>
                          <td align="left" valign="top"></td>
                        </tr>
                        
                        <tr>
                          <td>&nbsp;</td>
                          <td align="left" valign="top" height="28" class="content">Name Of Project </td>
                          <td align="left" valign="top">
                          <input name="nameOfPrj" id="nameOfPrj" type="text" class="textfield required" value="" tabindex="5" /></td>
                          <td align="left" valign="top">&nbsp;</td>
                        </tr>
                        <tr>
                          <td height="5"></td>
                          <td height="5" align="left" valign="top"></td>
                          <td height="5" align="left" valign="top"></td>
                          <td align="left" valign="top"></td>
                        </tr>
                        <tr>
                          <td height="28">&nbsp;</td>
                          <td class="content">End Date </td>
                          <td align="left" valign="top"><input name="endDate" type="text" id="endDate" class="textfield" value="" tabindex="7"/></td>
                          <td>&nbsp;</td>
                        </tr>
                        <tr>
                          <td height="5"></td>
                          <td height="5" align="left" valign="top"></td>
                          <td height="5" align="left" valign="top"></td>
                          <td align="left" valign="top"></td>
                        </tr>
                        <tr>
                          <td height="28">&nbsp;</td>
                          <td class="content">Project For </td>
                          <td align="left" valign="top"><input name="prjctFor" type="text" id="prjctFor" class="textfield" value="" tabindex="9"/></td>
                          <td>&nbsp;</td>
                        </tr>
                        <tr>
                          <td height="5"></td>
                          <td height="5" align="left" valign="top"></td>
                          <td height="5" align="left" valign="top"></td>
                          <td align="left" valign="top"></td>
                        </tr>
                        <tr>
                          <td height="28">&nbsp;</td>
                          <td class="content">Type Of Project</td>
                          <td align="left" valign="top">
                          <select name="typeOfPrj" id="typeOfPrj" class="textfield"  tabindex="11">
                          <option value="">Please Select</option>
                          <option value="R&D">R&D</option>
                          <option value="R&D AND PRODUCTION">R&D AND PRODUCTION</option>
                          <option value="PRODUCTION">PRODUCTION</option>
                          </select>
                          </td>
                          <td>&nbsp;</td>
                        </tr>
                        <tr>
                          <td height="5"></td>
                          <td height="5" align="left" valign="top"></td>
                          <td height="5" align="left" valign="top"></td>
                          <td align="left" valign="top"></td>
                        </tr>
                    </table></td>
                    <td width="330" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="67" height="21">&nbsp;</td>
                          <td width="221">&nbsp;</td>
                          <td width="259">&nbsp;</td>
                        </tr>
                        <tr>
                          <td >&nbsp;</td>
                          <td align="left" height="28" valign="top" class="content">Group/Division</td>
                          <td align="left" valign="top">
                          <input type="text" name="division" id="division" class="textfield" tabindex="2"/></td>
                        </tr>
                        <tr>
                          <td height="5"></td>
                          <td height="5" align="left" valign="top" class="content"></td>
                          <td height="5" align="left" valign="top"></td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <td align="left" height="28" valign="top" class="content">Name of User</td>
                          <td align="left" valign="top"><input type="text" name="nameOfUser" id="nameOfUser" class="textfield required" tabindex="4"/></td>
                        </tr>
                        <tr>
                          <td height="5"></td>
                          <td height="5" align="left" valign="top" class="content"></td>
                          <td height="5" align="left" valign="top"></td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <td align="left" valign="top" class="content">Start Date</td>
                          <td align="left" valign="top"><input type="text" name="strDate" id="strDate" class="textfield" tabindex="6"/></td>
                        </tr>
                        <tr>
                          <td height="5"></td>
                          <td height="5" align="left" valign="top" class="content"></td>
                          <td height="5" align="left" valign="top"></td>
                        </tr>
                        
                        <tr>
                          <td>&nbsp;</td>
                          <td align="left" height="28" valign="top" class="content">EMS</td>
                          <td align="left" valign="top"><input type="text" name="ems" id="ems" class="textfield" tabindex="8"/></td>
                        </tr>
                        <tr>
                          <td height="5"></td>
                          <td height="5" align="left" valign="top" class="content"></td>
                          <td height="5" align="left" valign="top"></td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <td align="left" height="28" valign="top" class="content">Used Components</td>
                          <td align="left" valign="top"><textarea  name="usedComp" id="usedComp" class="textarea1" tabindex="10"></textarea></td>
                        </tr>
                        <tr>
                          <td height="5"></td>
                          <td height="5" align="left" valign="top" class="content"></td>
                          <td height="5" align="left" valign="top"></td>
                        </tr>
                        
                    </table></td>
                  </tr>
                </table>
               
                </td>
              </tr>
              <tr>
                <td height="10" align="left" valign="top"></td>
              </tr>
              
              <tr>
                <td>&nbsp;</td>
              </tr>
              <tr>
              <td>
              
              </td>
              </tr>
              <tr>
                <td height="5"></td>
              </tr>
            </table>                       </td>
 		 </tr>
         
          
          <tr>
            <td align="left" valign="top">
            <a href="<%=application.getContextPath() %>/project/open.do"><input type="button" class="button-black-right"  value="Clear"/></a>
            <input type="button" class="button-black-right"  value="Edit" onclick="javascript: retriveProject()"/>
            <input type="submit" class="button-black-right" value="Submit" />   
           
             </td>
          </tr>
          <tr>
            <td height="10">
            	<div id="ajaxLoader" style="display:none" align="center"><img src="<%=application.getContextPath()%>/images/load.gif"/></div> 
            </td>
          </tr>
          <tr>
            <td align="right" valign="top">&nbsp;</td>
          </tr>
          
          <tr>
            <td align="left" valign="top">&nbsp;</td>
          </tr>
        </table>
        </form>
        <div id="projectDialog" style="display: none;">
                  <div id="projectSearchBox">
           <form action="<%= application.getContextPath()%>/project/getProjDet.do" method="post">
           			   <br />
                    <select name="projName" class="form" id="projId">
               			 <option value="">Please Select</option>
                   </select>
                  	<br />
                  	<br />
                    <input class="button-right" type="submit" id="ok" value="OK"/> 
                    </form>
                    </div>
                    
        </div>
        </td>
        <td>&nbsp;</td>
      </tr>
      
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      
    </table></td>
  </tr>
  <tr>
    <td height="40" align="left" valign="top" bgcolor="#0B0B0B">&nbsp;</td>
  </tr>
</table>
</body>
</html>
<script  type="text/javascript">
function retriveProject(){
	
	$.ajax({
		url:" <%=application.getContextPath()%>/project/searchProj.do",
		mimetype: "text/plain",
		cache:false,
		success: function(res){
			var e2=document.getElementById('projId');
			$('#projId')
		    .find('option')
		    .remove()
		    .end()
		   	;
			var temp=res.split("/");
			var o=document.createElement('option');
			o.value="";
			o.text="Please Select";
			e2.options.add(o);
			if(temp != null){
				for(var i=0;i<temp.length-1;i++){
					var o=document.createElement('option');
					var t=temp[i].split(",");
					o.value=t[0];
					o.text=t[1];
					e2.options.add(o);
				}
			}
			
		}

	});

var $dialog = $('#projectDialog').dialog({
                autoOpen: false,
                modal: true,
                width: 250,
                height: 120,
              				
            });
 			 
            $dialog.dialog('open');
}
</script>
<script>
$(document).ready(function(){
	$('#nameOfPrj').live('focusin',function(){
		$("#ajaxLoader").show();
		$.ajax({
			url:"<%=application.getContextPath()%>/project/searchProj.do",
			mimetype:"text/plain",
			cache:false,
			success: function(res){
				var te=new Array();
					var temp=res.split("/");
					//alert(temp[0]);
					if(temp != null){
						for(var i=0;i<temp.length-1;i++){
							var t=temp[i].split(",");
							te[i]=t[1];
								}
					}
					$('#nameOfPrj').autocomplete({
						source: te
					});
					jQuery('.ui-autocomplete').css({'font-size':'10px','font-family':'Arial','max-height': '100px',
				'overflow-y': 'auto', 'padding-right': '20px', 'overflow-x': 'hidden'});
				}

			}).done(function(html){
				$("#ajaxLoader").hide();
			}).fail(function(html){
				$("#ajaxLoader").hide();
				alert("Failed To Load the Data");
			});
		
		
		});
		});
</script>
<script>
$(document).ready(function(){
	$('#nameOfPrj').live('focusout',function(){
		var prjName=$("#nameOfPrj").val();
		var data="prjName="+prjName;
		$.ajax({
			url:"<%=application.getContextPath()%>/project/testProj.do",
			mimetype:"text/plain",
			data:data,
			method:"post",
			cache:false,
			success: function(res){
				if(res!=""){
					alert(res);
					$("#nameOfPrj").focus();
				}
				}

			});
		
		
		});
		});
</script>